
function category_nav_hide(show){
	if(show == 'show'){
		$("ul.category_header").slideDown(100);
	}else{
		$(".nav-main").children(".textSub").removeClass('active');
    	$("ul.category_header").slideUp(100);
	}
}
function category_select_search(show){
	if(show == 'show'){
		$('.list-searAll').slideDown(100);
	}else{
		$(".frmSearch").removeClass('active');
		$('.category-home-show').removeClass('active');
		$('.list-searAll').slideUp(100);
	}
}
$(".scrollDiv").click(function(){
	var mark = $(this).attr("href");
	$('html, body').animate({scrollTop:$(mark).position().top}, 'slow');
	return false;
})

$(".saveItem").click(function(){
	var obj = $(this);
	$.ajax({
	 	beforeSend:function(){
	 		obj.html('<div class="inline-loading"></div');
	 	},
        url:'ajax/cluster_ajax/save_item',
        data: {token:$(this).attr('rel'),csrf_token_cgd:$("#token").text(), name:$(this).attr('data-name') , price: $(this).attr('data-price'), shop: $(this).attr('data-shop'), source: $(this).attr('data-source'), img: $(this).attr('data-image')},
        method:'post',
        dataType: "json",
        success: function(data){
            if(data.error ==1){
            	obj.addClass('active').html('<span class="prSaveYes">Sản phẩm đã lưu &nbsp;</span><i class="fa fa-heart fa-lg"></i>');
            }else if(data.error == 0){
            	obj.html('<span>Bạn chưa đăng nhập &nbsp;</span><i class="fa fa-heart-o fa-lg"></i>');
            }else{
                obj.html('<span>'+data.msg+'&nbsp;</span><i class="fa fa-heart-o fa-lg"></i>')
            }
        }
    })
})
$(".userMenu").hover(
    function(){
        $(".nav-your-account").show();
    },
    function(){
        $(".nav-your-account").hide();
    }
)
$(function(){
   $('.tooltipRight').tooltip({placement: 'right'});
   $('.tooltipLeft').tooltip({placement: 'left'});
   $('.tooltipTop').tooltip({placement: 'top'});
   $('.tooltipBottom').tooltip({placement: 'bottom'});
});

$(document).ready(function() {
    $(".list-searAll").niceScroll({
        cursoropacitymin: 0.4,
        touchbehavior: true,
    });
});